<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const{ref,reactive}=Vue
    const app=Vue.createApp({
        template:`
        <h4>使用CompositionAPI实现todolist</h4>
        <div>
        <input v-model="inputVal" />
        <button @click="add">提交</button>
        </div>
        <div>
        <ul>
        <li v-for="(item,index) in todolist" :key="index">{{item}}</li>
        </ul>    
        </div>
        `,
        setup(props) {
            const inputVal=ref('');
            let todolist=reactive([]);
            function add(){
                todolist.push(inputVal.value);
                inputVal.value=''
            }
            return{ref,reactive,add,inputVal,todolist}
        }
    })
    app.mount("#app")
</script>
</html>